import Vue from 'vue'


/**
 * 从日期中截取时分
 */
Vue.filter("getTime", function(input) {
	if(!input) return "";
	return input.substr(10,6)
});
/**
 * 从日期中截取月日
 */
Vue.filter("getDate", function(input) {
	if(!input) return "";
	return input.substr(5,5)
});
/**
 * 时间戳获取年月日
 */
Vue.filter("date", function(input) {
	if(!input) return "";
	input = new Date(input)
	return `${input.getFullYear()}-${input.getMonth() + 1}-${input.getDate()}`
});
/**
 * 分钟转化为2小时25分
 */
Vue.filter("getHour", function(input) {
	if(!input) return "";
	input = Number(input);
	let h = parseInt(input/60);
	let m = input-h*60;
	return h+"小时"+m+"分";
});
/**
 * 舱位转化
 */
Vue.filter("cabinRank", function(input) {
	if(!input) return "";
	if(input=='Y') return "经济舱";
	if(input=='F') return "头等舱";
	if(input=='C') return "商务舱";
});

/**
 * 时间转化为12月01日(周二)
 */
Vue.filter("monDayWeek", function(input) {
	if(!input) return "";
	let d = new Date(input);	
	let weekDay = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"];	
	return `${d.getMonth() + 1}月${d.getDate()}日(${weekDay[d.getDay()]})`  
});

/**
 * 时间转化为 周二
 */
Vue.filter("getWeek", function(input) {
	if(!input) return "";
	let d = new Date(input);	
	let weekDay = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"];	
	return weekDay[d.getDay()]  
});


/**
 * 火车座位类型
 */
Vue.filter("trainSeatType", function(input) {
	if(input=='0') return "商务座";
	if(input=='1') return "特等座";
	if(input=='2') return "一等座";
	if(input=='3') return "二等座";
	if(input=='4') return "高级软卧";
	if(input=='5') return "软卧";
	if(input=='6') return "硬卧";
	if(input=='7') return "软座";
	if(input=='8') return "硬座";
	if(input=='9') return "无座";
	if(input=='10') return "其他";
});
/**
 * 火车票类型
 */
Vue.filter("trainTicketType", function(input) {
	if(input=='0') return "成人票";
	if(input=='1') return "儿童票";	
});
/**
 * 旅客类型
 */
Vue.filter("passengerType", function(input) {
	if(input=='1') return "成人";
	if(input=='2') return "儿童";	
});
/**
 * 性别
 */
Vue.filter("gender", function(input) {
	if(input=='Maile') return "男";
	if(input=='Female') return "女";	
	if(input=='Unknown ') return "保密";	
});
/**
 * 证件类型
 */
Vue.filter("docType", function(input) {
	if(input=='1') return "身份证";
	if(input=='2') return "护照";	
	if(input=='3') return "港澳通行证";	
	if(input=='4') return "台湾证";	
	if(input=='5') return "回乡证";	
});

//订单状态转化
Vue.filter("otherStatus", function(input) {
	if(input == null || input == undefined || input == "") return "";
	if(input=="WAIT_AUDIT") return "退票待审核";
	if(input=="WAIT_REFUND") return "退票中";
	if(input=="REFUND_SUCCESS") return "退票成功";
	if(input=="REFUND_FAILURE") return "退票失败";
	if(input=="REFUND_OVER") return "已退票";	
	
	if(input=="waiting_for_review") return "改签待审核";	
	if(input=="waiting_for_process") return "改签待处理";	
	if(input=="payed") return "改签已支付";	
	if(input=="gathering_success") return "改签成功";	
	if(input=="review_fail") return "改签审核不通过";	
	if(input=="returned") return "改签退回";	
	if(input=="cancel") return "改签取消";	

	else return "未知";
});


//订单状态转化
Vue.filter("orderStatus", function(input) {
	if(input == null || input == undefined) return "";
	if(input=="0") return "待支付";
	if(input=="1") return "处理中";
	if(input=="2") return "待出票";
	if(input=="4") return "出票完成";
	if(input=="5") return "已取消";
	if(input=="6") return "待确认人数";
	if(input=="9") return "已退款";
	if(input=="10") return "预定失败";
	if(input=="-1") return "押金未支付";
	else return input;
});


//酒店订单订单状态转化
Vue.filter("hotelStatus", function(input) {
	if(input == null || input == undefined) return "";
	if(input=="N") return "新单";
	if(input=="A") return "已确认";
	if(input=="F") return "已入住";
	if(input=="C") return "已结帐";
	if(input=="Z") return "删除另换酒店";
	if(input=="D") return "删除";
	if(input=="B") return "NO SHOW";
	if(input=="O") return "满房";
	if(input=="G") return "变价";
	if(input=="U") return "特殊满房";
	if(input=="H") return "变更";
	if(input=="B1") return "有预定未查到";
	if(input=="B2") return "待查";
	if(input=="B3") return "暂不确定";
	if(input=="S") return "特殊";
	else return input;
});